//
//  SISSNetworkingManager+Comment.m
//  SISSAPP
//
//  Created by 优房网 on 2017/5/25.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSNetworkingManager+Comment.h"

@implementation SISSNetworkingManager (Comment)

// 6.11.1 获取经纪人收到的评价信息 GET请求
- (void)requestAgentReceivedCommentInfoWithCommentType:(NSInteger)commentType spId:(NSString *)spId success:(void (^)(SISSCommentScoreModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":spId,
                                 @"comment_type":@(commentType)
                                 };
    
    [kNetworkManager GETWithURLString:URL_AGENT_RECEIVIED_COMMENT_INFO parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.11.1 获取经纪人收到的评价信息: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSCommentScoreModel *model = [SISSCommentScoreModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}


// 6.11.2 获取经纪人收到的带看评价 GET请求
- (void)requestAgentReceivedTakeLookCommentInfoWithPageNo:(NSInteger)pageNo spId:(NSString *)spId success:(void (^)(SISSCommentBaseModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSInteger pageSize = 20;
    NSDictionary *parameters = @{
                                 @"spId":spId,
                                 @"pageNo":@(pageNo),
                                 @"pageSize":@(pageSize)
                                 };
    
    [kNetworkManager GETWithURLString:URL_AGENT_RECEIVIED_TAKE_COMMENT parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.11.2 获取经纪人收到的带看评价: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSCommentBaseModel *baseModel = [SISSCommentBaseModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(baseModel);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}


// 6.11.3 获取经纪人收到的服务评价信息 GET请求
- (void)requestAgentReceivedServiceCommentInfoWithPageNo:(NSInteger)pageNo spId:(NSString *)spId success:(void (^)(SISSCommentBaseModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSInteger pageSize = 20;
    NSDictionary *parameters = @{
                                 @"spId":spId,
                                 @"pageNo":@(pageNo),
                                 @"pageSize":@(pageSize)
                                 };
    
    [kNetworkManager GETWithURLString:URL_AGENT_RECEIVIED_SERVICE_COMMENT parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.11.3 获取经纪人收到的服务评价信息: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSCommentBaseModel *baseModel = [SISSCommentBaseModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(baseModel);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}


// 6.12.4  获取经纪人发出的评价信息 GET请求
- (void)requestAgentSendCommentInfoWithCommentType:(NSInteger)commentType pageNo:(NSInteger)pageNo success:(void (^)(SISSCommentBaseModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSInteger pageSize = 20;
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId,
                                 @"pageNo":@(pageNo),
                                 @"pageSize":@(pageSize),
                                 @"comment_type":@(commentType)
                                 };
    
    [kNetworkManager GETWithURLString:URL_AGENT_SEND_COMMENT parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.12.4 获取经纪人发出的评价信息: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSCommentBaseModel *baseModel = [SISSCommentBaseModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(baseModel);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}


@end
